<?php
/*****************************
* PHPwork官方网址： ruanjiesoft.com
* PHPwork应用官方QQ群： 317075601
* PHPwork应用开发者QQ： 1980572700
* 不得使用本软件用于非法用途，不得违反国家法律。
*************************************/

namespace application\cms\controller;

class Base{

    protected $config;
    protected $nav;

    function __construct() {
        // 配置信息
        $sql="select * from ".tablename('rj_cms_config')." where name='应用配置' ";
        $config = $GLOBALS['db']->query($sql)->fetch();
        $this->config = json_decode( $config['value'],true );

        //上部导航
        $this->nav['上部'] = $this->_nav('上部',0);
        // 上部 2级导航
        foreach($this->nav['上部'] as $k => $v){
            $this->nav['上部'][$k]['nav_2'] = $this->_nav( '上部',$v['id'] );
        }

        //底部导航
        $this->nav['底部'] = $this->_nav('底部',0);

        // 浏览记录
		$data = ['ip'=>get_ip(),'url'=>$_SERVER['REQUEST_URI'],'hit_day'=>date('Y-m-d'),'create_time'=>time()];
        pdo_insert('rj_cms_hit_log',$data);

    }
	
	
    // 导航
    protected function _nav($place,$parent_id=0){
        $sql="select * from ".tablename('rj_cms_nav')." where status=1 and place='$place' and parent_id=$parent_id order by list_order,id ";
        return $GLOBALS['db']->query($sql)->fetchall();
    }



}